<template>
  <div class="detailPageCss">
    <div class="titleCss">添加题库</div>
    <div class="bodyCss">
      <el-form ref="form" :model="formData" label-width="140px">
        <el-row>
          <el-form-item label="题库类型">
            <el-select v-model="formData.data1" placeholder="请选择" style="width:100%;">
              <el-option
                v-for="item in data1Options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="题目管理">
            <el-button type="primary" size="mini">添加题目</el-button>
            <el-button type="primary" size="mini">导入题目</el-button>
            <el-button type="primary" size="mini">导入题目模板</el-button>
          </el-form-item>
        </el-row>
      </el-form>
      <div class="tableCss">
        <el-table
          max-height="520"
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            type="index"
            label="序号"
            width="55"
            align="center">
          </el-table-column>
          <el-table-column
            prop="data1"
            label="题目类型"
            width="100">
            <template #default="scope">
              {{ data1Map[scope.row.data1] }}
            </template>
          </el-table-column>
          <el-table-column
            prop="data2"
            label="题目标题">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            width="120">
            <template #default="scope">
              <el-button @click="configBtn(scope.row)" type="text" size="small">题目配置</el-button>
              <el-button @click="deleteBtn(scope.row)" type="text" size="small">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
      <el-button type="primary" @click="submitBtn">保存</el-button>
    </div>
  </div>
</template>

<script>
import { getSelectOptionsFun } from '@/utils/business.js'
export default {
  data(){
    return{
      formData:{
        data1:null,
        data2:null,
        data3:null,
      },
      data1Options:[],
      tableData:[],
      data1Map:{
        0:'填空题',
        1:'判断题',
        2:'单选选择题',
        3:'多项选择题',
      }
    }
  },
  mounted(){
    this.data1Options = getSelectOptionsFun()
    this.getList()
  },
  methods:{
    deleteBtn(){

    },
    configBtn(){
      
    },
    getList(){
      const random = Math.floor( Math.random() * 60) + 1
      this.tableData = []
      for( let i=0;i<random ; i++){
        const random1 = Math.floor( Math.random() * 4)
        this.tableData.push({
          data1: random1,
          data2: '【测试数据】新版基本公共卫生服务规范规定居民健康档案的编码采用（）位编码新版基本公共卫生服务规范规定居民健康档案的编码采用（）位编码'
        })
      }
    },
    submitBtn(){
      this.$router.back()
    },
    goBackBtn(){
      this.$router.back()
    },
  },
}
</script>

<style lang="scss" scoped>
.detailPageCss{
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc( 100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss{
    text-align: center;
    font-size: 18px;
    font-weight: bold;
  }
  .bodyCss{
    margin-top: 40px;
    width: 90%;
    margin-left: 5%;
    .tableCss{
      width: calc( 100% - 70px);
      margin-left: 70px;
      position: relative;
    }
  }
  .bottomBtnCss{
    margin-top: auto;
    text-align: right;
  }
}
::v-deep .el-table__row{
  td:not(.is-hidden):last-child{
    border-left:1px solid #dcdfe6;
  }

}
::v-deep .el-table__header{
  th:not(.is-hidden):last-child{
    border-left:1px solid #dcdfe6;
  }
}
</style>